<extend name="Public:common" />
<block name="body">
    <body>
        <div class="container">
            <div style="padding: 30px">

            </div>
            <div>
                <form class="form-horizontal" role="form">
                    <input id="openid" type="hidden" name="openid" value="{$_user['openid']}">
                    <div class="form-group has-success">
                        <label class="control-label col-sm-2">昵称：</label>
                        <div class="col-sm-10">
                            <input id="nickname" name="nickname" value="{$_user['nickname']}" type="text" class="form-control">
                        </div>
                    </div>
                    <div class="form-group has-success">
                        <label class="control-label col-sm-2">性别：</label>
                        <div class="col-sm-10">
                            <label class="radio-inline">
                                <input id="nan" type="radio" name="sex" value="1" <eq name="_user['sex']" value="1"> checked="checked" </eq> > 男
                            </label>
                            <label class="radio-inline">
                                <input id="nv" type="radio" name="sex" value="2" <eq name="_user['sex']" value="2"> checked="checked" </eq> > 女
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <a id="sub" type="submit" class="btn btn-success">ok</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <script>
            $(function(){
                $('#sub').click(function(){
                    var openid = $('#openid').val();
                    var url = "{:U('Home/User/save')}";
                    var nickname = $('#nickname').val();
                    var sex = $(":radio:checked").val();
                    if(sex == ''){
                        sex = 0;
                    }
                    var param = {
                        nickname:nickname,
                        sex:sex,
                        openid:openid
                    };
                    Jloading(true);
                    $.post(url,param,function(res){
                        Jloading(false);
                        if(res == 1){
                            Jmessage({ type: 'success',info:"操作成功"});
                            setTimeout(WeixinJS.closeWindow(),3000);
                        }else{
                            Jmessage({ type: 'error',info:"操作失败"});
                        }
                    });
                });
            });
        </script>
    </body>
</block>
</html>